/*
 * sagacity.js 0.1 - common Javascript for enterprise information system
 *
 * Copyright (c) 2007 zhongxuchen (sagacity.com)
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * $Date: 2007-09-16 23:42:06 -0400 (Sun, 16 Sep 2007) $
 * $Rev: 3353 $
 */
 
 
function sag_menu_openclose(menuId)
{
	 var menuItems=document.getElementById(menuId);
	 if(menuItems!=null)
	 {
	 		if(menuItems.className=="show")
	 			menuItems.className="un_show";
	 		else
	 			menuItems.className="show";
	 }
	 
}

function sag_favorite_openclose(menuId,imageId)
{
	 var menuItems=document.getElementById(menuId);
	 if(menuItems!=null)
	 {
	 		if(menuItems.className=="show")
	 		{
	 			menuItems.className="un_show";
	 			document.getElementById(imageId).src="../resources/images/left-menu-arrow-dw.gif";
	 		}
	 		else
	 		{
	 			menuItems.className="show";
	 			document.getElementById(imageId).src="../resources/images/left-menu-arrow-up.gif";
	 		}
	 }
	 
}

/*
*字符串全局替换
*/
String.prototype.replaceAll = stringReplaceAll;

function stringReplaceAll(AFindText,ARepText){
raRegExp = new RegExp(AFindText,"g");
return this.replace(raRegExp,ARepText)
}


/*
*页面html传参数
*/
var htmlRequest = { 
QueryString : function(val) { 
var uri = window.location.search; 
var re = new RegExp("" +val+ "=([^&?]*)", "ig"); 
return ((uri.match(re))?(uri.match(re)[0].substr(val.length+1)):null); 
} 
} 

/*
*
*点击子系统图标，菜单页面加载子系统名称
*以及检测菜单开合的状态，设置默认值
*/
function pageOnloadSubSys()
{
	var subtitle=htmlRequest.QueryString("subsysTitle");
	var subName=htmlRequest.QueryString("subsysName");
	if(subtitle!=null&& subtitle!="")
	{
	   document.getElementById("sub_title").title=subtitle.replaceAll("\'","");
	   document.getElementById("sub_title").innerText=subtitle.replaceAll("\'","");
  }
  var parentFrame = top.document.getElementById("mainframe");
  if(parentFrame.cols=="9,*")
  {
  		parentFrame.cols="200,*";
	 		document.getElementById("left_menu_main").style.display="block";
	 		document.getElementById("left_menu_main").style.width="160px";
	 		document.getElementById("left_menu_main").style.margin="4px 0 0 5px";
	 		
	 		document.getElementById("left_menu_card").style.display="block";
	 		document.getElementById("left_menu_card").style.width="21px";
	 		document.getElementById("left_menu_card").style.margin="14px 0 0 6px";
	 	
	 		document.getElementById("leftMenuBtn").style.left="191px"; 
	 	 	document.getElementById("leftMenuBtn").src="../resources/images/left_menu_close.gif";
  }
 
  initializeMenu("left_menu_main","../resources/data/menuData.xml",subName);
}

function openOrCloseMenu(obj,path)
{
	 
	 var parentFrame = top.document.getElementById("mainframe");
	 
	 if(parentFrame.cols=="9,*")
	 {
	 		parentFrame.cols="200,*";
	 		document.getElementById("left_menu_main").style.display="block";
	 		document.getElementById("left_menu_main").style.width="160px";
	 		document.getElementById("left_menu_main").style.margin="4px 0 0 5px";
	 		
	 		document.getElementById("left_menu_card").style.display="block";
	 		document.getElementById("left_menu_card").style.width="21px";
	 		document.getElementById("left_menu_card").style.margin="14px 0 0 2px";
	 	
	 		obj.style.left="191px"; 
	 	 	obj.src=path+"/left_menu_close.gif";
	 }
	 else
	 {	 	   
	 	  parentFrame.cols="9,*";
	 	  document.getElementById("left_menu_main").style.display="none";
	 	  document.getElementById("left_menu_main").style.width="0px";
	 	  document.getElementById("left_menu_main").style.margin="0px 0 0 0px";
	 	 	
	 	 	document.getElementById("left_menu_card").style.display="none";
	 	  document.getElementById("left_menu_card").style.width="0px";
	 	  document.getElementById("left_menu_card").style.margin="0px 0 0 0px";
	 	  
	 	  obj.style.left="0px";
	 	 	
	    obj.src=path+"/left_menu_open.gif";
	 }
	 
	 //如果处于分屏状态，修改页面宽度
	 top.document.frames.workbench.adjustPageWidth();
}


function updateNavigationTitle(navigationTitle)
{
	 if(navigationTitle==null||navigationTitle=="")
	 		return;
	 var header=top.frames["topFrame"].document.getElementById("navigationTitle");
	 
	 if(navigationTitle.indexOf(navigationTitle.length-1)!=",")
	 		navigationTitle+=",";
   var naviagtionStr="你当前的位置:";
   var count=0;
   var index=0;
   
 	 while(navigationTitle!=""&&(index=navigationTitle.indexOf(","))!=-1)
   {
   	   if(count>0)
   	   		naviagtionStr+="<img src='../resources/images/address-arrow2.gif' alt='' />\n";
   	   naviagtionStr+="<a href='####'>"+navigationTitle.substr(0,index)+"</a>\n";
   	   navigationTitle=navigationTitle.substr(index+1);
   	   count++;
   }
	 header.innerHTML=naviagtionStr;  
}